﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class User_UserPwdEdit : WebUI.Page.BasePage
{
    protected int Userid;      //声明一个公用变量，用于存放会员编号

    protected void Page_Load(object sender, EventArgs e)
    {
        #region 权限逻辑

        //if (Session["MemberPowerArray"] != null && Session["MemberPowerArray"].ToString() != "")
        //{


        //    //权限数组Session

        //    if (StringinArray("MGXSZ_MMXG_Edit", (string[])Session["MemberPowerArray"]))
        //    {
        //        ibtnedit.Visible = true;
        //    }
        //    else
        //    {
        //        ibtnedit.Visible = false;
        //    }

        //}
        //else
        //{
        //    //Response.Write("<script language=javascript>parent.window.parent.window.location.href='Login.aspx'</script>");
        //}


        #endregion



        if (Session["UserID"] != null && Session["UserID"].ToString() != "")
        {
            Userid = Convert.ToInt32(Session["UserID"].ToString());


            if (!IsPostBack)
            {
                //showMemberInfo(Memberid);

            }

        }
        else
        {
            string cmsinteurl = ConfigMg.UIConfig.cisIntegrationcms.ToString();
            Response.Write("<script language=javascript>parent.window.parent.window.location.href='" + cmsinteurl + "'</script>");
        }
    }

    #region 修改新密码
    protected void ibtnedit_Click(object sender, ImageClickEventArgs e)
    {
        Cisoft.IntegrationSystem.BLL.UserBO bllUser = new Cisoft.IntegrationSystem.BLL.UserBO();
        Cisoft.IntegrationSystem.Model.UserMO userVO = new Cisoft.IntegrationSystem.Model.UserMO();

        userVO = bllUser.GetUserInfo(Userid);

        Cisoft.IntegrationSystem.Common.MD5 md5 = new Cisoft.IntegrationSystem.Common.MD5();

        string strpwdold = pwdBoxold.Text.Trim().ToString();

        strpwdold = md5.HashString(strpwdold);
        string strpwd = "888888";
        strpwd = ConfigMg.UIConfig.cisforgetpwd.ToString();
        strpwd = pwdBox.Text.Trim().ToString();                              //新密码

        strpwd = md5.HashString(strpwd);                                            //md5加密处理

        if (userVO.UserPassword.ToString() == strpwdold)
        {


            userVO.UserPassword = strpwd;   //新密码



            if (bllUser.EditRecord(userVO)>0)
            {
                PageRight("修改成功", "UserPwdEdit.aspx", "返回", "");
            }
            else
            {
                PageError("修改失败", "UserPwdEdit.aspx", "返回", "");
            }
        }
        else
        {
            PageError("旧密码错误，请重新尝试", "UserPwdEdit.aspx", "返回", "");
        }


    }
    #endregion



    #region  返回事件
    /// <summary>
    /// 返回事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ibtnback_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("UserPwdEdit.aspx");
    }
    #endregion
}
